<?php
/**
 * Created by PhpStorm.
 * User: luzy
 * Date: 2018/1/1
 * Time: 上午9:37
 */

class Point extends Base_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('point_model');
    }

    public function checkUserComplish()
    {
        if(!isset($_SESSION)) session_start();
        if (isset($_SESSION['uid'])){
            //判定用户是否已经填写过问卷
            $iscomplished=$this->point_model->checkUserComplish($_SESSION['uid'],1);
            $this->success($iscomplished);
        }else{$this->error();}
    }

    public function submitAns()
    {
        $post=$this->input->post();
        if (!isset($post['uid'])||!is_numeric($post['uid'])
            ||!isset($post['ans'])||empty($post['ans'])) $this->error();
        $uid=(int)$post['uid'];
        $ans=$post['ans'];
        $this->point_model->submitAns($uid,$ans,1);
        $this->success($ans);
    }

    public function getStatis($courseid=1)
    {
        $res=$this->point_model->getStatis($courseid);
        $this->load->view('presult',array('results'=>$res));
    }
}